<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>购物车</title>
    <
    <style type="text/css">
        .dialog-wrapper {
            position: relative;
            z-index: 99999;
        }

        html b, html b a, html body, html caption, html dd, html del, html div, html dl, html dt, html em, html fieldset, html form, html h1, html h2, html h3, html h4, html h5, html h6, html html, html i, html iframe, html img, html, html label, html legend, html li, html ol, html p, html s, html samp, html small, html span, html strong, html table, html tbody, html td, html textarea, html tfoot, html th, html thead, html tr, html u, html ul {
            box-sizing: content-box;
        }

        b, b a, body, caption, dd, del, div, dl, dt, em, fieldset, form, h1, h2, h3, h4, h5, h6, html, i, iframe, img, input, label, legend, li, ol, p, s, samp, small, span, strong, table, tbody, td, textarea, tfoot, th, thead, tr, u, ul {
            margin: 0;
            padding: 0;
            border: 0;
            vertical-align: baseline;
            box-sizing: border-box;
        }

        .lrc-dialog, .single-button {
            position: fixed;
            left: 50%;
            top: 50%;
            z-index: 999;
            border-radius: 5px;
            overflow: hidden;
            border: 4px solid rgba(0, 0, 0, .1);
        }

        .dialog-mask {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            opacity: .15;
            z-index: 998;
            background-color: #000;
        }

        .lrc-dialog button, .single-button button {
            padding: 0;
            cursor: pointer;
            outline: 0;
            border: 0;
        }

        .dialog-close-notitle {
            width: 16px;
            height: 16px;
            background: url(//misc.360buyimg.com/user/cart/css/i/commontips/common-tips-close.png) no-repeat;
        }

        .dialog-close {
            cursor: pointer;
            display: block;
            position: absolute;
            z-index: 1000;
            top: 10px;
            right: 10px;
            overflow: hidden;
            font-size: 0;
        }

        button, select {
            text-transform: none;
        }

        button, input, optgroup, select, textarea {
            font-family: sans-serif;
            line-height: 1.15;
            margin: 0;
        }

        .dialog-body {
            padding: 10px;
            background: #fff;
        }

        .ui-dialog-content {
            padding: 20px 0;
        }

        .ui-dialog-content .common-tips-dialog {
            min-width: 420px;
            text-align: center;
        }

        .ui-dialog-content .common-tips-dialog .error {
            background-image: url(//misc.360buyimg.com/user/cart/css/i/commontips/common-tips-error.png);
        }

        .ui-dialog-content .common-tips-dialog .common-tips-icon {
            width: 50px;
            height: 50px;
            margin-bottom: 15px;
            display: inline-block;
            position: relative;
            vertical-align: middle;
            background-size: cover;
            background-repeat: no-repeat;
        }

        .ui-dialog-content .common-tips-dialog .common-tips-tit {
            color: #333;
            font-size: 18px;
            font-weight: 700;
            line-height: 28px;
            vertical-align: middle;
        }

        .ui-dialog-content .common-tips-dialog .common-tips-opts {
            margin-top: 15px;
        }

        .ui-dialog-content .common-tips-dialog .common-tips-opts .yes {
            color: #fff;
            background: #d1392a;
        }

        .ui-dialog-content .common-tips-dialog .common-tips-opts .comon-tips-btn {
            display: inline-block;
            height: 34px;
            line-height: 34px;
            vertical-align: middle;
            text-align: center;
            padding: 0 25px;
            cursor: pointer;
            text-decoration: none;
            border: 1px solid #d1392a;
        }
    </style>
    <link rel="icon" href="/static/cart//img/心04.png" type="/image/x-icon"/>
    <link rel="stylesheet" href="/static/cart//css/One_bdyStyle.css">
    <link rel="stylesheet" href="/static/cart//css/index.css">
    <script src="/static/cart/js/jquery-3.1.1.min.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/cart//css/One_mainFoot.css">
    <link rel="stylesheet" href="/static/cart//css/font-awesome-4.7.0/css/font-awesome.css"/>

</head>
<body>
<header>
    <a name="mao1">
        <div class="header">

            <ul class="header-left">
                <li>
                    <a href="http://www.drygoods.top">首页</a>
                </li>

            </ul>
            <ul class="header-right">
                <li>
                    <a th:if="${session.loginUser==null}" href="http://auth.drygoods.top/login.html"
                       style="color: red;">你好，请登录</a>
                    <a th:if="${session.loginUser!=null}" style="color: red;">
                        [[${(session.loginUser!=null)?session.loginUser.username:''}]]
                    </a>
                </li>
                <li>
                    <a th:if="${session.loginUser==null}" href="http://auth.drygoods.top/reg.html">
                        免费注册
                    </a>
                </li>
                <li class="spacer"></li>
                <li><a href="http://member.drygoods.top/orderList.html">我的订单</a></li>
                <li class="spacer"></li>

            </ul>
            <div style="clear: both;"></div>
        </div>

    </a>
</header>


<div class="one_search">

    <div class="one_sousuo">
        <div class="one_search_top">
            <div class="one_top_left">
                <a href="http://www.drygoods.top" class="one_left_logo"><img style="width: 120px;height: 100px;margin-top: -40px;"
                                                                             src="/static/index/img/logo.png"></a>
                <a href="http://www.drygoods.top" class="one_left_link">购物车</a>
            </div>
            <div class="one_top_right">
                <input type="text" class="one_right_txt" placeholder="" onfocus="this.placeholder=''"
                       onblur="this.placeholder='' ">
                <input onclick="search()" type="button" value="搜索" class="one_right_btn"
                       style="width: 56px;height: 28px">
            </div>
        </div>
        <div class="one_search_load" th:if="${session.loginUser==null}">
            <img src="/static/cart/img/shop_07.jpg" class="one_load_wraing">
            <span>您还没有登录！登录后购物车的干货将保存到您账号中</span>
            <a href="#"><input type="button" onclick="login()" value="立即登录" class="one_load_btn"></a>
        </div>
    </div>
</div>
<div class="One_BdyShop">
    <div class="OneBdy_box">
        <div class="One_tabTop">
            <div class="One_Topleft">
                <span>全部干货</span>

            </div>

        </div>
        <div class="One_ShopTop">
            <ul>
                <li><input type="checkbox" class="allCheck">全选</li>
                <li>干货</li>
                <li>单价</li>
                <li>数量</li>
                <li>小计</li>
                <li>操作</li>
            </ul>
        </div>

        <div class="One_ShopCon">
            <h1 th:if="${cart.items==null}">
                购物车没有干货了，快去<a href="http://www.drygoods.top">购物吧！</a>
            </h1>
            <ul th:if="${cart.items!=null}">
                <li th:each="item:${cart.items}">
                    <div>
                    </div>
                    <div>
                        <ol>
                            <li><input type="checkbox" th:attr="skuId=${item.skuId}" class="itemCheck"
                                       th:checked="${item.check}"></li>
                            <li>
                                <dt>
                                    <a th:href="'http://item.drygoods.top/'+${item.skuId}+'.html'">
                                        <img th:src="${item.image}" alt="">
                                    </a>
                                </dt>
                                <dd>
                                    <p style="width: 200px">
                                        <a th:href="'http://item.drygoods.top/'+${item.skuId}+'.html'"
                                           th:text="${item.title}">TCL 55A950C 55英寸32核</a>
                                        <br/>
                                        <br/>
                                        <span th:each="attr:${item.skuAttr}" th:text="${attr+'&nbsp;&nbsp;'}">尺码: 55时 超薄曲面 人工智能</span>
                                    </p>

                                </dd>
                            </li>
                            <li>
                                <p class="dj">￥[[${#numbers.formatDecimal(item.price,1,2)}]]</p>

                            </li>
                            <li>
                                <p th:attr="skuId=${item.skuId}">
                                    <span class="CountOpsBtn">-</span>
                                    <span class="CountOpsNum" th:text="${item.count}">5</span>
                                    <span class="CountOpsBtn">+</span>
                                </p>

                            </li>
                            <li style="font-weight:bold"><p class="zj">
                                ￥[[${#numbers.formatDecimal(item.totalPrice,1,2)}]]</p></li>
                            <li>
                                <p th:attr="skuId=${item.skuId}" class="deleteItem">删除</p>

                            </li>
                        </ol>
                    </div>
                </li>
            </ul>
        </div>
        <div class="One_ShopFootBuy fix1">
            <div>
                <ul>
                    <li>
                        <input type="checkbox" class="allCheck">
                        <span>全选</span>
                    </li>
                    <li>删除选中的干货</li>
                    <li>移到我的关注</li>
                    <li>删除所有购物项</li>
                </ul>
            </div>
            <div>
                <font style="color:#e64346;font-weight:bold;" class="sumNum"> </font>&nbsp;

                <ul>
                    <li><img src="/static/cart/img/buyNumleft.png" alt=""></li>
                    <li><img src="/static/cart/img/buyNumright.png" alt=""></li>
                </ul>
            </div>
            <div>
                <ol>
                    <li>总价:<span style="color:#e64346;font-weight:bold;font-size:16px;" class="fnt">￥[[${#numbers.formatDecimal(cart.totalAmount,1,2)}]]</span>
                    </li>
                    <li>优惠:￥[[${#numbers.formatDecimal(cart.reduce,1,2)}]]</li>

                </ol>
            </div>
            <div>
                <button onclick="toTrade()" type="button">去结算</button>
            </div>
        </div>
    </div>
</div>

<div class="One_isDel">
    <p>
        <span>删除</span><span><img src="/static/cart/img/错误.png" alt=""></span>
    </p>
    <div>
        <dl>
            <dt><img src="/static/cart/img/感叹三角形 (2).png" alt=""></dt>
            <dd>
                <li>删除干货？</li>
                <li>您可以选择移到关注，或删除干货。</li>
            </dd>
        </dl>
    </div>
    <div>
        <button onclick="removeItem()" type="button">删除</button>

    </div>
</div>
<div class="One_moveGzIfNull">
    <p>
        <span>删除</span><span><img src="/static/cart/img/错误.png" alt=""></span>
    </p>
    <dl>
        <dt><img src="/static/cart/img/感叹三角形 (2).png" alt=""></dt>
        <dd>请确认需要删除所选干货吗？</dd>
    </dl>
    <div style="height: 50px;clear: left;text-align: center;">
        <a onclick="deleteSelectPart()"
           style="background: #E13639;color: white;border-radius: 5px;padding: 5px;border: none;outline: none;"
           type="button">
            删除
        </a>
    </div>

</div>
<div class="One_moveMyGz">
    <p>
        <span>删除</span><span><img src="/static/cart/img/错误.png" alt=""></span>
    </p>
    <div>
        <dl>
            <dt><img src="/static/cart/img/感叹三角形 (2).png" alt=""></dt>
            <dd>
                <li>移到关注</li>
                <li>移动后选中干货将不再购物车中显示</li>
            </dd>
        </dl>
    </div>
    <div>
        <button type="button">确定</button>
        <button type="button">取消</button>
    </div>
</div>
<div class="One_clearShop">
    <p>
        <span>提示</span><span><img src="/static/cart/img/错误.png" alt=""></span>
    </p>
    <dl>
        <dt><img src="/static/cart/img/感叹三角形 (2).png" alt=""></dt>
        <dd>是否清空购物车？</dd>
    </dl>
    <div style="height: 50px;clear: left;padding-top: 20px;text-align: center;">
        <a href="http://cart.drygoods.top/delete/allCartItems"
           style="background: #E13639;color: white;border-radius: 5px;padding: 5px;border: none;outline: none;"
           type="button">
            删除
        </a>

    </div>
</div>
<!--底部-->

<div class="one_footer">

</div>
<!--提示没有选择购买项-->
<div class="dialog-wrapper" id="tipNotSelectBuy" style="display: none">
    <div class="lrc-dialog" style="margin-left: -216px; margin-top: -131px;">
        <button class="dialog-close dialog-close-notitle" onclick="closeTipNotSelectBuy()"></button>
        <div class="dialog-body">
            <div class="ui-dialog-content">
                <div class="common-tips-dialog ac">
                    <div class="common-tips-icon-cont"><i class="common-tips-icon error"></i></div>
                    <div><p class="common-tips-tit">请至少选中一件商品！</p></div>
                    <p class="common-tips-opts"><a href="#none" onclick="closeTipNotSelectBuy()"
                                                   class="comon-tips-btn yes">知道了</a></p></div>
            </div>
        </div>
    </div>
    <div class="dialog-mask" aria-hidden="true"></div>
</div>
</body>
<script src="js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/index/js/text.js"></script>
<script type="text/javascript" src="/static/index/js/header.js"></script>
<script type="text/javascript" src="/static/index/js/secend.js"></script>
<script type="text/javascript" src="/static/index/js/zz.js"></script>
<script type="text/javascript" src="/static/index/js/index.js"></script>
<script type="text/javascript" src="/static/index/js/left,top.js"></script>
<script type="text/javascript" src="/static/index/js/catalogLoader.js"></script>
<script type="text/javascript" th:inline="javascript">

    function closeTipNotSelectBuy() {
        document.getElementById("tipNotSelectBuy").style.display = 'none';
    }

    function deleteSelectPart() {

        let items = $(".itemCheck");
        let deleteIds = new Array();
        for (let i = 0; i < items.length; i++) {
            if (items[i].checked) {
                let skuId = items[i].getAttribute("skuId");
                deleteIds.push(skuId);
                console.log(skuId);
            }
        }
        $.ajax({
            url: "http://cart.drygoods.top/deleteItem/selectPart",
            data: JSON.stringify(deleteIds),
            processData: false, //默认true，设置为 false，不需要进行序列化处理
            cache: false, //设置为false将不会从浏览器缓存中加载请求信息
            async: false, //发送同步请求
            contentType: 'application/json', //避免服务器不能正常解析文件---------具体的可以查下这些参数的含义
            dataType: 'json', //不涉及跨域  写json即可
            type: 'post',
            success: function (date) {
                console.log(date);
                window.location.href = "http://cart.drygoods.top/cartList.html";
            },
            error: function (error) {
                console.log(error);
                $(".One_mb").hide();
                $(".One_moveGzIfNull").hide();
            }
        })

    }

    function toTrade() {
        let items = $(".itemCheck");
        let deleteIds = new Array();
        let flag = false;
        for (let i = 0; i < items.length; i++) {
            if (items[i].checked) {
                window.location.href = "http://order.drygoods.top/toTrade";
                flag = true;
            }
        }
        if (!flag) {
            document.getElementById("tipNotSelectBuy").style.display = 'block';
        }
    }

    function toItem(skuId) {
        window.location.href = "http://item.gmall.top:8084/" + skuId + ".html";
    }

    function login() {
        var s = encodeURIComponent("http://cart.gmall.top:8087/cartList");
        window.location.href = "http://auth.drygoods.top/login.html";
    }

    function checkSku(chkbox) {
        var skuId = $(chkbox).attr("value");
        var checked = $(chkbox).prop("checked");
        var isCheckedFlag = "0";
        if (checked) {
            isCheckedFlag = "1";
        }
        var param = "isChecked=" + isCheckedFlag + "&" + "skuId=" + skuId;
        $.post("checkCart", param, function (data) {
            sumSumPrice();
        });

    }

    //封装总价钱函数
    function sumSumPrice() {
        //         var zzj=0;
        //         $(".check").each(function () {
        //             if($(this).prop("checked")){
        //                 var zj = $(this).parents("ol").find(".zj").html().substring(1);
        //                 zzj=zzj+parseFloat(zj);
        //             }
        //             $(".fnt").html("￥"+zzj+".00")
        //         });
    }

    /*    //购物车结算固定定位
        $(document).scroll(function(){
            if($(window).scrollTop()>50){
                $(".fix").hide();
            }else{
                $(".fix").show();
            }
        })*/


    //购物车顶端tab
    $(".One_Topleft span:last-child").mouseover(function () {
        $(".One_Topleft span:first-child").css({
            "color": "black",
            "border-bottom": "none"
        })
        $(this).css({
            "cursor": "pointer",
            "color": "#E4393C",
            "border-bottom": "2px solid red"
        })
    }).mouseout(function () {
        $(this).css({
            "color": "black",
            "border-bottom": "none"
        });
        $(".One_Topleft span:first-child").css({
            "cursor": "pointer",
            "color": "#E4393C",
            "border-bottom": "2px solid red"
        })
    })
    //立即登录
    $(".one_search_load input:button").click(function () {
        $(".One_mb").show();
        $(".One_DengLu").show();
    })
    //去结算
    $(".One_ShopFootBuy>div:last-child button").mouseover(function () {
        $(this).css("cursor", "pointer");
    })
    $(".One_ShopFootBuy>div:last-child button").click(function () {
        $(".One_mb").show();
        $(".One_DengLu").show();
    })
    //buyNum
    $(".One_ShopFootBuy>div:nth-child(2)").mouseover(function () {
        $(this).css("cursor", "pointer")
    })
    $(".One_ShopFootBuy>div:nth-child(2)").click(function () {
        $(this).children("ol").toggle();
        $(this).children("ul").toggle();
        var dis = $(".One_ShopFootBuy>div:nth-child(2) ol").css("display");
        if (dis == "none") {
            $(".One_ShopFootBuy>div:nth-child(2) img").css("transform", "rotateX(0)")
        } else if (dis == "block") {
            $(".One_ShopFootBuy>div:nth-child(2) img").css("transform", "rotateX(180deg)")
        }
    })
    //右侧固定定位
    $(".One_RightFix ul>li:not(:first-child)").mouseover(function () {
        $(this).css({
            "cursor": "pointer",
            "background": "#C91423"
        })
        $(this).children("ol").stop().animate({
            "left": "-75px"
        }, 200)
    }).mouseout(function () {
        $(this).css("background", "#7A6E6E");
        $(this).children("ol").stop().animate({
            "left": "75px"
        }, 200)
    })
    //右侧底部固定定位
    $(".One_RightbtmFix ul>li").mouseover(function () {
        $(this).css({
            "cursor": "pointer",
            "background": "#C91423"
        })
        $(this).children("ol").stop().animate({
            "left": "-55px"
        }, 200)
    }).mouseout(function () {
        $(this).css("background", "#7A6E6E");
        $(this).children("ol").stop().animate({
            "left": "55px"
        }, 200)
    })
    //登录弹框tab切换
    $(".One_DengLu>div:nth-child(3) ul li").mouseover(function () {
        $(this).css("cursor", "pointer")
    })
    $(".One_DengLu>div:nth-child(3) ul li").click(function () {
        var i = $(this).index();
        $(this).css({
            "color": "#E64346",
            "font-weight": "bold"
        })
            .siblings("li").css({
            "color": "black",
            "font-weight": "normal"
        })
        $(".One_DengLu>div:nth-child(3) ol li").eq(i).show().siblings().hide()
    })
    //优惠券
    $(".One_ShopBottom>div:nth-child(2) img").click(function () {
        $(".One_mb").show();
        $(".One_DengLu").show();
    })
    //配送地址hover效果
    $(".One_Topright span:last-child").mouseover(function () {
        $(this).children(".One_Local").css("display", "block")
    }).mouseout(function () {
        $(".One_Local>ul>li").eq(0).children("ol").css("display", "block")
        $(this).children(".One_Local").css("display", "none")
    })

    $(".One_Local>ul>li").eq(0).children("ol").css("display", "block")
    $(".One_Local>ul>li").mouseover(function () {
        var i = $(this).index();
        $(this).css("cursor", "pointer");
        $(this).children("ol").css("display", "block")
    }).mouseout(function () {
        $(".One_Local>ul>li").eq(0).children("ol").css("display", "block")
        $(this).children("ol").css("display", "none")
    })

    $(".One_Local>ul>li>ol li").mouseover(function () {
        $(this).css({
            "cursor": "pointer",
            "color": "#e64346"
        })
    }).mouseout(function () {
        $(this).css("color", "#005AA0")
    })

    $(".One_Local>ul>li>ol li").click(function () {
        $(this).parent().parent().children("label").html($(this).html())
    })
    //购物车全选反选
    $(".One_ShopTop ul li:first-child .allCheck").click(function () {
        if ($(".One_ShopTop ul li:first-child .allCheck").is(":checked")) {
            // $(".check").each(function(index){
            $(".check").prop("checked", true);
            $(".check").parent().parent().parent().css("background", "#fff4e8");
            $(".itemCheck").prop("checked", true)
            $(".One_ShopFootBuy>div:first-child ul li:first-child .allCheck").prop("checked", true)
            // })
        } else {
            // $(".check").each(function(){
            $(".check").parent().parent().parent().css("background", "none");
            $(".check").prop("checked", false);
            $(".itemCheck").prop("checked", false)
            $(".One_ShopFootBuy>div:first-child ul li:first-child .allCheck").prop("checked", false)
            // })
        }
        let items = $(".itemCheck");
        let parames = new Array();
        for (let i = 0; i < items.length; i++) {
            let skuId = items[i].getAttribute("skuId");
            let check = items[i].checked ? 1 : 0;
            parames.push({"skuId": skuId, "check": check});
            console.log(skuId, check);
        }
        $.ajax({
            url: "http://cart.drygoods.top/checkAllCartItem",
            data: JSON.stringify(parames),
            processData: false, //默认true，设置为 false，不需要进行序列化处理
            cache: false, //设置为false将不会从浏览器缓存中加载请求信息
            async: false, //发送同步请求
            contentType: 'application/json', //避免服务器不能正常解析文件---------具体的可以查下这些参数的含义
            dataType: 'json', //不涉及跨域  写json即可
            type: 'post',
            success: function (date) {
                console.log(date);
            }
        })

    })
    $(".One_ShopFootBuy>div:first-child ul li:first-child .allCheck").click(function () {
        if ($(".One_ShopFootBuy>div:first-child ul li:first-child .allCheck").is(":checked")) {
            $(".check").prop("checked", true);
            $(".check").parent().parent().parent().css("background", "#fff4e8");
            $(".itemCheck").prop("checked", true)
            $(".One_ShopTop ul li:first-child .allCheck").prop("checked", true)
        } else {
            $(".check").parent().parent().parent().css("background", "none");
            $(".check").prop("checked", false);
            $(".itemCheck").prop("checked", false)
            $(".One_ShopTop ul li:first-child .allCheck").prop("checked", false)
        }
    })
    $(".One_ShopBottom>div:first-child span:first-child .allCheck").click(function () {
        if ($(".One_ShopBottom>div:first-child span:first-child .allCheck").is(":checked")) {
            $(".check").prop("checked", true);
            $(".check").parent().parent().parent().css("background", "#fff4e8");
        } else {
            $(".check").parent().parent().parent().css("background", "none");
            $(".check").prop("checked", false);
        }
    })
    //如果子选择框没有选中则父选框取消全选
    $(".check").click(function () {
        $(".check").each(function () {
            if ($(this).prop("checked") == true) {
                $(".allCheck").prop("checked", false);
            }
        })
    })
    //子选择框全部选中复选框也选中
    $(".check").click(function () {
        if ($(".check[class='check']:checked").length == $(".check[class='check']").length) {
            $(".allCheck").prop("checked", true);
        } else {
            $(".allCheck").prop("checked", false)
        }
    })
    //删除已选的干货
    $(".One_ShopFootBuy>div:first-child ul li:nth-child(2)").click(function () {
        // $(".check").each(function(){
        if ($(".check").is(":checked") == false) {
            $(".One_mb").show();
            $(".One_moveGzIfNull").show();
        } else {
            $(".One_mb").show(); //蒙版显示
            $(".One_isDel").show(); //删除弹框显示
            $(".One_moveGzIfNull").hide();
        }
    })
    //确定删除弹框移入我的关注
    $(".One_isDel>div:last-child button:last-child").click(function () {
        $(".One_isDel").hide();
        $(".One_mb").show();
        $(".One_DengLu").show();
    })
    //移到我的关注
    $(".One_ShopFootBuy>div:first-child ul li:nth-child(3)").click(function () {
        // $(".check").each(function (index) {
        if ($(this).is(":checked") == false) {
            $(".One_mb").show();
            $(".One_moveMyGz").show();
        } else {
            $(".One_mb").show();
            $(".One_moveMyGz").show();
        }
        // })
    })
    //点击×号关闭
    $(".One_moveGzIfNull>p span:last-child img").click(function () {
        $(".One_mb").hide();
        $(".One_moveGzIfNull").hide();
    })
    $(".One_moveMyGz>p span:last-child img").click(function () {
        $(".One_mb").hide();
        $(".One_moveMyGz").hide();
        $(".One_moveGzIfNull").hide();
    })
    $(".One_clearShop>p span:last-child img").click(function () {
        $(".One_mb").hide();
        $(".One_clearShop").hide();
    })
    //移到我的关注取消按钮点击关闭
    $(".One_moveMyGz>div:last-child button:last-child").click(function () {
        $(".One_mb").hide();
        $(".One_moveMyGz").hide();
    })
    //移到我的关注确定按钮点击登录弹框弹出
    $(".One_moveMyGz>div:last-child button:first-child").click(function () {
        $(".One_moveMyGz").hide();
        let cartItems = [[${cart.items}]];
        if (cartItems != null) {
            for (let i = 0; i < cartItems.length; i++) {
                if (cartItems[i].check == true) {
                    var res = attentionSku(cartItems[i].skuId, cartItems[i].title, cartItems[i].image, cartItems[i].spuId);
                }
            }
            console.log(res);
            if (res === "success") {
                deleteSelectPart();
            }
        }
        console.log("移到我的关注确认按钮");
    })

    //移到关注
    function attentionSku(skuId, skuName, skuImg, spuId) {
        console.log(skuId + skuName + skuImg + spuId);
        var flage = true;
        $.ajax({
            url: "http://member.drygoods.top/member/membercollectsku/save/attention",
            data: JSON.stringify({
                "skuId": skuId,
                "skuName": skuName,
                "skuImg": skuImg,
                "spuId": spuId
            }),
            processData: false, //默认true，设置为 false，不需要进行序列化处理
            cache: false, //设置为false将不会从浏览器缓存中加载请求信息
            async: false, //发送同步请求
            // crossDomain: true,
            contentType: 'application/json', //避免服务器不能正常解析文件---------具体的可以查下这些参数的含义
            dataType: 'json', //不涉及跨域  写json即可
            type: 'post',
            xhrFields: {
                withCredentials: true //默认情况下，标准的跨域请求是不会发送cookie的
            },
            success: function (date) {
                console.log(date, 3);
            },
            error: function (error) {
                console.log(error, 2);
                let responseText = error.responseText;
                if (responseText.search("欢迎登录") == -1) {
                    console.log("其他错误")
                    console.log(error)
                } else {
                    console.log("没登录");
                    window.location.href = "http://auth.drygoods.top/login.html"
                }
                console.log(error);
                flage = false;
            }
        });
        if (flage) {
            return "success";
        } else {
            return "error";
        }
    };


    $(".One_DengLu>p:first-child span:last-child img").click(function () {
        $(".One_mb").hide();
        $(".One_DengLu").hide();
    })

    //删除所有购物项
    $(".One_ShopFootBuy>div:first-child ul li:nth-child(4)").click(function () {
        $(".One_mb").show();
        $(".One_clearShop").show()

    })
    //购物车+ -
    //鼠标移入变小手
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(4) p:first-child span").mouseover(function () {
        $(this).css("cursor", "pointer")
    })
    //+
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(4) p:first-child span:last-child").click(function () {
        var add = $(this).prev("span").html();
        add++;
        $(this).prev("span").html(add);
        //总价
        var dj = $(this).parent().parent().prev().children(".dj").html().substring(1);
        var sl = $(this).prev("span").html();
        $(this).parent().parent().parent().children("li:nth-child(5)").children(".zj").html("￥" + dj * sl + ".00")
        sumSumPrice();

    })
    //-
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(4) p:first-child span:first-child").click(function () {
        var jian = $(this).next("span").html();
        jian--;
        if (jian <= 0) {
            jian = 0;
        }
        $(this).next("span").html(jian);
        //总价
        var dj = $(this).parent().parent().prev().children(".dj").html().substring(1);
        var sl = $(this).next("span").html();
        $(this).parent().parent().parent().children("li:nth-child(5)").children(".zj").html("￥" + dj * sl + ".00")
        sumSumPrice();

    })
    //选中当前干货背景变色
    $(".check").each(function (index) {
        $(".check").eq(cartList).click(function () {
            if ($(this).is(":checked")) {
                $(this).parent().parent().parent().css("background", "#fff4e8");
                $(this).parent().parent().parent().parent().children("div:last-child").css("background", "#fff4e8")
            } else {
                $(this).parent().parent().parent().parent().children("div:last-child").css("background", "none")
                $(this).parent().parent().parent().css("background", "none")
            }
        })
    })
    //干货删除鼠标移入变色
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(6) p").mouseover(function () {
        $(this).css({
            "cursor": "pointer",
            "color": "#e64346"
        });
    }).mouseout(function () {
        $(this).css({
            "cursor": "pointer",
            "color": "gray"
        });
    })
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(6) p:nth-child(2)").click(function () {
        $(".One_mb").show();
        $(".One_moveMyGz").show();
    })
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(6) p:last-child").click(function () {
        $(".One_mb").show();
        $(".One_DengLu").show();
    })
    //点击删除
    //点击删除出现弹框
    $(".One_isDel>p img").click(function () {
        $(".One_mb").hide();
        $(".One_isDel").hide();
    })
    $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(6) p:first-child").click(function () {
        $(".One_mb").show();
        $(".One_isDel").show();
        var that = $(this);
        //确定删除
        /*        $(".One_isDel>div:last-child button:first-child").click(function(){
                    $(".One_mb").hide();
                    $(".One_isDel").hide();
                    that.parent().parent().parent().parent().remove();
                    // 移除结账固定定位
                    // if($(".check").length==1){
                    // 	$(".fix").remove();
                    // }
                    if($(".fix").offset().top>$(".fix1").offset().top){
                        $(".fix").hide();
                    }
                    if($(".check").length==0){
                        $(".allCheck").prop("checked",false);
                        $(".sumNum").html("0");
                        $(".fnt").html("￥ 0.00");
                    }
                })*/
    })
    /*    //页面滚动删除去结算固定定位隐藏
        $(document).scroll(function(){
            if($(".fix").offset().top>$(".fix1").offset().top){
                $(".fix").hide();
            }
        })*/
    $(".One_isDel>div:last-child button").mouseover(function () {
        $(this).css("cursor", "pointer");
    })

    $(".One_ShopFootBuy>div:first-child ul li:not(:first-child)").mouseover(function () {
        $(this).css({
            "cursor": "pointer",
            "color": "#e64346"
        })
    }).mouseout(function () {
        $(this).css("color", "black")
    })

    //封装总价钱函数
    function sumSumPrice() {
        console.log("计算总价");
        var zzj = 0;
        $(".check").each(function () {


            if ($(this).prop("checked")) {
                console.log("check!!" + $(this).parents("ol").find(".zj").html());
                var zj = $(this).parents("ol").find(".zj").html().substring(1);
                console.log(" 价格：" + zj);
                zzj = zzj + parseFloat(zj);
            }
            $(".fnt").html("￥" + zzj + ".00")
        })

        /*        $(".One_ShopCon ul li>div:nth-child(2) ol li:nth-child(5) .zj").each(function(){
                    kong+=parseFloat($(this).html().substring(1))
                })
                $(".fnt").html("￥"+kong+".00")*/
    }

    //封装总数量函数
    function sumSumNum() {
        var kong = 0;
        $(".One_ShopCon ul li>div:nth-child(2) ol>li:nth-child(4) p:first-child span:nth-child(2)").each(function () {
            kong += parseFloat($(this).html())
        })
        $(".sumNum").html(kong);
    }

    $(".One_ShopCon ul li>div:nth-child(2)>ol>li:nth-child(2)>dd").mouseover(function () {
        $(this).css({
            "cursor": "pointer",
            "color": "#e64346"
        })
    }).mouseout(function () {
        $(this).css("color", "black")
    })
    //更多促销下拉
    $(".One_ShopCon ul li>div:nth-child(2) ol li:nth-child(3) p:nth-child(2)").click(function () {
        $(this).parent().children(".nmbd").slideToggle(300);
        var dis = $(this).parent().children(".nmbd").css("display");
        console.log(dis);
        // if(dis=="block"){
        // 	$(".hahaha").css("transform","rotateX(-180deg)")
        // }else{
        // 	$(".hahaha").css("transform","rotateX(360deg)")
        // }
    })
    $(".nmbd dd:last-child button:first-child").click(function () {
        $(this).parent().parent().slideUp(100)
    })
    $(".nmbd dd:last-child button:last-child").click(function () {
        $(this).parent().parent().slideUp(100)
    })


    //active
    $(".one_main_div1 .one_main_ul>li").mouseover(function () {
        $(".one_main_div1 .one_main_ul>li").removeClass("active");
        $(this).addClass("active");
    })
    //选项卡
    $(".one_main_div1 .one_main_ul li").mouseover(function () {
        $(".one_main_div1_1").eq($(this).index()).stop(true).show().siblings().stop(true).hide()
    })

    $(function () {
        //声明变量记录索引
        var index = 0;
        //点击右边按钮
        //忽略重复点击开关
        var toggle = true
        $(".arrow-right").click(function () {

            if (toggle == false) {
                return
            }
            toggle = false
            cartList++;
            if (cartList > $('.fade li').length - 1) {
                cartList = 0;
            }

        });

        //点击左边按钮
        $(".arrow-left").click(function () {
            if (toggle == false) {
                return
            }
            toggle = false
            cartList--;
            if (cartList < 0) {
                cartList = $('.fade li').length - 1;
            }
            $('.pagination ul li').eq(cartList).addClass('active').siblings().removeClass('active')
            $(".slider>ul>li").eq(cartList).fadeIn(500, function () {
                toggle = true
            }).siblings("li").fadeOut(500);
        });
        //点击分页器
        $('.pagination ul li').mouseover(function () {
            var paging = $(this).index()
            //变颜色
            $(this).addClass('active').siblings().removeClass('active')
            //与图片关联
            $(".slider>ul>li").eq(paging).fadeIn(1000).siblings("li").fadeOut(1000);

        })
    });
    $(".fade li>div a").mouseover(function () {
        $(this).children("p").children("img").attr("src", "img/one_mian_gwc2.png")
    }).mouseout(function () {
        $(this).children("p").children("img").attr("src", "img/one_mian_gwc1.png")
    })
    $(".itemCheck").click(function () {
        let skuId = $(this).attr("skuId");
        let check = $(this).prop("checked");
        location.href = "http://cart.drygoods.top/checkItem?skuId=" + skuId + "&check=" + (check ? 1 : 0);
    })
    $(".CountOpsBtn").click(function () {
        let skuId = $(this).parent().attr("skuId");
        let num = $(this).parent().find(".CountOpsNum").text();
        location.href = "http://cart.drygoods.top/countItem?skuId=" + skuId + "&num=" + num;
    })
    var deleteId = 0;

    function removeItem() {
        location.href = "http://cart.drygoods.top/deleteItem?deleteId=" + deleteId;
    }

    $(".deleteItem").click(function () {
        deleteId = $(this).attr("skuId");
    })

    function search() {
        var keyword = $(".one_right_txt").val()
        window.location.href = "http://search.drygoods.top/list.html?keyword=" + keyword;
    }
</script>
</html>
